package cn.yj.common.interfaces;

import cn.yj.common.emums.PayFrom;
import cn.yj.common.emums.PayType;
import cn.yj.common.entity.PayRefundOrder;
import cn.yj.common.entity.PayResult;
import cn.yj.common.entity.RefundParams;
import cn.yj.common.entity.RefundQueryParams;
import cn.yj.common.exception.PayException;
import com.alibaba.fastjson.JSONObject;

import javax.xml.rpc.ServiceException;
import java.io.IOException;
import java.util.Map;

/**
 * 支付来源选择器；根据不同的支付发起端选择不同的处理器：App发起支付、PC端发起支付...
 *
 * @author 永健
 * @since 2022-02-18 12:15
 */
public interface IPayFromExecutor<R extends PayResult, Q> {

    R underOrder(PayFrom from, Q request) throws PayException;

    <N> N  refund(RefundParams params) throws PayException;

    /**
     * 将map参数转换成借口所需对象
     *
     * @param from   请求类型：APP、小程序、网站之类的
     * @param params 统一下单接口参数
     *
     * @return 接口参数对象
     */
    Q getRequestParams(PayFrom from, Map<String, Object> params);

    <N> N queryOrder(String outTradeNo);

    PayRefundOrder queryRefundOrder(RefundQueryParams params) throws PayException;

}
